home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Classic
/
CD CLASSIC #1.iso
/
3df
/
3df.asm
next >
Wrap
Assembly Source File
|
1991-04-18
|
11KB
|
403 lines
page 66,132
;
; Assembly Language Support for fast3d
; in Turbo Pascal 5.0. Gene Ressler
;
.MODEL TPASCAL
N_PIX_X equ 640
N_PIX_Y equ 192
BUF_SIZE equ 16384
.DATA
ALIGN 2
x0 dw ?
y0 dw ?
oldVec dw N_PIX_X dup (?)
newVec dw N_PIX_X dup (?)
minUpdtPtr dw ?
maxUpdtPtr dw ?
scrBuf db BUF_SIZE dup (?)
.CODE
VIDEO equ 10h
SELECT_MODE equ 0
PALLETTE equ 11
SET_BACKGROUND equ 0
SET_PALLETTE equ 1
SCREEN_SEG equ 0B800h
SetVideo PROC NEAR mode: BYTE
PUBLIC SetVideo
mov ah, SELECT_MODE
mov al, mode
int VIDEO
ret
SetVideo ENDP
SetPallette PROC NEAR pal: BYTE
PUBLIC SetPallette
mov ah, PALLETTE
mov bh, SET_PALLETTE
mov bl, pal
and bl, SET_PALLETTE
int VIDEO
ret
SetPallette ENDP
SetBackground PROC NEAR pal: BYTE
PUBLIC SetBackground
mov ah, PALLETTE
mov bh, SET_BACKGROUND
mov bl, pal
and bl, 0Fh
int VIDEO
ret
SetBackground ENDP
ClearScreen PROC NEAR
PUBLIC ClearScreen
mov ax, SCREEN_SEG
mov es, ax
xor ax, ax
xor di, di
mov cx, BUF_SIZE/2
cld
rep stosw
ret
ClearScreen ENDP
InitCloud PROC NEAR
PUBLIC InitCloud
mov ax, ds
mov es, ax
mov cx, N_PIX_X
mov dx, cx
mov ax, -1
mov di, offset oldVec
cld
rep stosw
mov cx, dx
mov di, offset newVec
rep stosw
mov minUpdtPtr, offset newVec + 2*(N_PIX_X-1)
mov maxUpdtPtr, offset newVec
ret
InitCloud ENDP
UpdateCloud PROC NEAR
PUBLIC UpdateCloud
mov si, minUpdtPtr
mov cx, maxUpdtPtr
sub cx, si
jb noUpdateNeeded
shr cx, 1
inc cx
mov di, si
add di, offset oldVec - offset newVec
mov ax, ds
mov es, ax
cld
rep movsw
mov minUpdtPtr, offset newVec + 2*(N_PIX_X-1)
mov maxUpdtPtr, offset newVec
noUpdateNeeded:
ret
UpdateCloud ENDP
ClearImage PROC NEAR
PUBLIC ClearImage
mov ax, ds
mov es, ax
xor ax, ax
mov cx, BUF_SIZE/2
mov di, offset scrBuf
cld
rep stosw
ret
ClearImage ENDP
; Show image buffer on CGA.
ShowImage PROC NEAR
PUBLIC ShowImage
mov ax, SCREEN_SEG
mov es, ax
mov bx, N_PIX_Y/2
mov si, offset scrBuf
xor di, di
mov dx, 40
cld
showLoop:
mov cx, dx
rep movsw ; Shoot 80 bytes to even buffer.
add di, 8192-80
mov cx, dx
rep movsw ; Now 80 bytes to odd buffer
sub di, 8192 ; Get ready for next even buffer row.
dec bx
jnz showLoop
ret
ShowImage ENDP
MovePen PROC NEAR x: word, y: word
PUBLIC MovePen
mov ax, x
mov x0, ax
mov ax, y
mov y0, ax
ret
MovePen ENDP
;
; drawLine -- Draw a line from current pen to x, y
; and update the current pen.
; Consider and update cloud.
DrawLine PROC NEAR x1:word, y1:word
PUBLIC DrawLine
LOCAL c1:word, c2:word, p:word
LOCAL newVecPtr:word, oldVecPtr: word
LOCAL yInc:word, xInc:word
jmp overProcs
IFDEF PROFILE
PUBLIC initX
PUBLIC initY
PUBLIC initXinc
PUBLIC initYinc
PUBLIC plot
ENDIF
initX PROC NEAR
mov ax, cx
pop si
pop di
mov bx, offset oldVec
add bx, di ; ptr := base+x*2
add bx, di
mov oldVecPtr, bx
mov bx, offset newVec
add bx, di
add bx, di
mov newVecPtr, bx
mov cx, di
shr di, 1
shr di, 1
shr di, 1
add di, offset scrBuf
and cl, 7
mov bl, 080h
shr bl, cl
mov cx, ax
jmp si
initX ENDP
initY PROC NEAR
pop si
pop ax
shl ax, 1
shl ax, 1
shl ax, 1
shl ax, 1
add di, ax
shl ax, 1
shl ax, 1
add di, ax
jmp si
initY ENDP
initXinc PROC NEAR
pop si
pop ax
pop dx
cmp dx, ax
jle negXinc
mov xInc, 0
jmp si
negXinc:
mov xInc, 1
jmp si
initXinc ENDP
initYinc PROC NEAR
pop si
pop ax
pop dx
cmp dx, ax
jle negYinc
mov yInc, 80
jmp si
negYinc:
mov yInc, -80
jmp si
initYinc ENDP
plot PROC NEAR
push bx
mov bx, newVecPtr
cmp di, [bx]
jae notNewMin
mov [bx], di
cmp bx, minUpdtPtr
jae okOnLeft
mov minUpdtPtr, bx
okOnLeft:
cmp bx, maxUpdtPtr
jbe okOnRight
mov maxUpdtPtr, bx
okOnRight:
notNewMin:
mov bx, oldVecPtr
cmp di, [bx]
pop bx
jae notVis
or [di], bl
notVis:
ret
plot ENDP
overProcs:
mov cx, x1
sub cx, x0
jge dxNotNeg
neg cx
dxNotNeg:
mov dx, y1
sub dx, y0
jge dyNotNeg
neg dx
dyNotNeg:
cmp cx, dx
jg dxGTdy
jmp dxLEdy
dxGTdy:
mov ax, dx
add ax, ax
mov c1, ax
sub ax, cx
mov p, ax
mov ax, dx
sub ax, cx
add ax, ax
mov c2, ax
mov cx, x0
mov dx, x1
cmp cx, dx
jle x0LEx1